//
//  propertyViewController.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/7/8.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "propertyViewController.h"
#import "propertyCollectionViewCell.h"

static NSString * Indentifer = @"propertyCollectionViewCell";

@interface propertyViewController ()
<UICollectionViewDataSource,UICollectionViewDelegate>

@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIScrollView *scroview;
@property (strong, nonatomic) IBOutlet UICollectionView *collectionView;

@end

@implementation propertyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initViewLayout];
}

- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
//    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroview];
    
    _scroview.contentSize = flexibleSize(CGSizeMake(0, 569), NO);
    
    
    UICollectionViewFlowLayout *FlowLayout =[[UICollectionViewFlowLayout alloc]init];
    FlowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    FlowLayout.minimumInteritemSpacing = 0*VerticalRatio();
    FlowLayout.minimumLineSpacing = 0*VerticalRatio();
    self.collectionView.collectionViewLayout = FlowLayout;
    
    [self.collectionView registerNib:[UINib nibWithNibName:Indentifer bundle:nil] forCellWithReuseIdentifier:Indentifer];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
}


- (IBAction)back:(id)sender {
    [self.navigationController  popViewControllerAnimated:YES];
}


#pragma mark - <UICollectionViewDelegate && UICollectionViewDataSource>
//定义 UICollectionView 的 cell 个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 6;
}

//定义UICollectionView Cell的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(106*VerticalRatio(), 130*VerticalRatio());
}

//定义 UICollectionView 的边距
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 0, 0, 0);
}


//定义 UICollectionView cell 展示的内容
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    propertyCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:Indentifer forIndexPath:indexPath];
    cell.backgroundColor = [UIColor clearColor];
    cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"property%d",indexPath.row+1]];
    
    NSArray *labelArray = [NSArray array];
    labelArray = @[@"水费",@"电费",@"物业费",@"缴费记录",@"报事报修",@"物业消息"];
    cell.label.text = labelArray[indexPath.row];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        //水费
        UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"HomeStoryboard" bundle:nil];
        UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"water"];
        [self.navigationController   pushViewController:page animated:YES];
        
    } else if (indexPath.row == 1) {
        //电费
        UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"HomeStoryboard" bundle:nil];
        UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"electricity"];
        [self.navigationController   pushViewController:page animated:YES];
        
    } else if (indexPath.row == 2) {//物业费
        
    } else if (indexPath.row == 3) {//缴费记录
        UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"HomeStoryboard" bundle:nil];
        UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"PayFeeHistory"];
        [self.navigationController   pushViewController:page animated:YES];
    } else if (indexPath.row == 4) {//报事报修
        UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"HomeStoryboard" bundle:nil];
        UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"CommitFix"];
        [self.navigationController   pushViewController:page animated:YES];

    }else if (indexPath.row == 5) {//物业消息
        
    }
}




@end
